//
//  APPView.m
//  iLongHua
//
//  Created by iMuse on 15-4-28.
//  Copyright (c) 2015年 mySelf. All rights reserved.
//

#import "APPView.h"
#import "AppCenter.h"

@implementation APPView
{
    UIImageView * iconImageView;
    
    UILabel     * label;
    UILabel     * line;
}

-(id)init
{
    self = [super init];
    if (self)
    {
        [self initView];
    }
    
    return self;
}
-(void)updateConstraints
{
    [super updateConstraints];
    [iconImageView autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:10];
    [iconImageView autoAlignAxisToSuperviewAxis:ALAxisHorizontal];
    [iconImageView autoSetDimension:ALDimensionHeight toSize:30];
    [iconImageView autoSetDimension:ALDimensionWidth toSize:30];
    
    [label autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:iconImageView withOffset:10.0f];
    [label autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:10];
    [label autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:10];
    [label autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:10];
    
    [line autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:10];
    [line autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:10];
    [line autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:0];
    [line autoSetDimension:ALDimensionHeight toSize:0.3];

}
-(void) initView
{
    self.backgroundColor           = [UIColor whiteColor];
    
    [self addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
   
    
    iconImageView                  = [UIImageView newAutoLayoutView];
  
    iconImageView.contentMode      = UIViewContentModeScaleAspectFit;
    [self addSubview:iconImageView];
    
    label                           = [UILabel newAutoLayoutView];
    label.font                      = [UIFont systemFontOfSize:12];
    label.textColor                 = [UIColor blackColor];
    [self addSubview:label];
    
    line                            = [UILabel newAutoLayoutView];
    line.backgroundColor            = [AppCenter color:@"188,188,188"];
    [self addSubview:line];
    
}
-(void)setLineHiddent
{
    line.hidden = YES;
}
-(void)setLaeblText:(NSString*)_text
{
    label.text = _text;
}
-(void)setImageView:(UIImage*)_image
{
    iconImageView.image = _image;
}

-(void) click:(id)_sender
{

    
    if ([self.delagate respondsToSelector:@selector(onTapAppImage:)])
    {
        [self.delagate performSelector:@selector(onTapAppImage:) withObject:[NSString stringWithFormat:@"%d",self.tag]];
    }
}
















@end
